﻿Imports System.IO



Public Class ImageConverter
    Public Shared Function toBinary(ByVal img As System.Drawing.Image) As Byte()
        Dim Result As Byte()
        Dim ms As New MemoryStream
        Try
            Using ms
                img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
                Result = ms.ToArray
            End Using
        Catch ex As Exception
            Throw New Exception("Image conversion problem")
        End Try
        Return Result
    End Function
End Class
